"use strict";

var util = require('util');
var BaseFilter = require('./FilterBase.js');

/**
 * 纯粹数字
 * @constructor
 */
function FilterNumber(__isDebug) {
  this.__isDebug = __isDebug;
  this.__passed = [];
  this.__blocked = [];
  this.number = '某几两一二三四五六七八九十零百千万亿点半1234567890.壹贰叁肆伍陆柒捌玖拾佰仟';
}
util.inherits(FilterNumber, BaseFilter);
module.exports = FilterNumber;

var theProto = FilterNumber.prototype;

theProto.detailFilter = function (str) {
  var i = str.length - 1;
  for (; i >= 0; i--) {
    if (this.number.indexOf(str.charAt(i)) < 0) {
      break;
    }
  }
  // i<0表明全是数字 return i<0 ? false: true
  return i >= 0;
};

/**
 * 对 str进行变换
 * @param str
 * @returns {*}
 */
theProto.__transform = function (str) {
  // +-*/
  return str.replace(/[\.\+\-\*//]/g, '');
};

//
//var sample = ["几百","一一", "一百", "一千万.5", "两两", "0.9", "零点九", "零点以后"];
//new FilterNumber(true).__testScript(sample);